Merges this PDF file with one or more PDF existing files with optional passwords for each file.
public void MergeWith(
PDFFile[] sourceFiles,
string destinationFileName
)
public void mergeWith(
PDFFile[] sourceFiles,
java.lang.String destinationFileName
);
public:
void MergeWith(
array<PDFFile^>^ sourceFiles,
String^ destinationFileName
)
def MergeWith(self,] sourceFiles,destinationFileName):
sourceFiles
An array of PDFFile objects that contain the names and optional password of the source files to merge with this PDFFile. Must not be null and contain at least one item.
destinationFileName
Name of the destination PDF file to be created. If the value of this parameter is null, then the filename set in FileName will be updated.
This method will merge two or more existing PDF files to form a new file containing all the pages from the pre-existing PDF files. The new file will be constructed as follows:
All the PDF files must pre-exist on disk and be valid. The sourceFiles parameter must not contain any null items.
To use this method, associate this PDFFile object with a valid PDF file and optional password. You can achieve this by either using the PDFFile(string fileName) or PDFFile(string fileName, string password) constructors or set the filename and optional password directly into the FileName and Password properties. You do not need to call Load before using this method.
This method will use the following properties of this PDFFile object:
If one or more of the files to merge with are encrypted with a password, then set the required password in its PDFFile item in the sourceFiles array. If none of the files are encrypted, then you can use the MergeWith(string[] sourceFileNames, string destinationFileName) version of this method to pass a list of System.String's for the filenames instead.
If you wish to merge only a portion (not all the pages) of one or more PDF files, you can use the PDFFile.MergeFiles method instead.
using Leadtools.WinForms;
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Controls;
using Leadtools.Drawing;
using Leadtools.ImageProcessing;
using Leadtools.Pdf;
using Leadtools.Svg;
public void PDFFileMergeWithExample()
{
string sourceFileName1 = Path.Combine(LEAD_VARS.ImagesDir, @"File1.pdf");
string sourceFileName2 = Path.Combine(LEAD_VARS.ImagesDir, @"File2.pdf");
string sourceFileName3 = Path.Combine(LEAD_VARS.ImagesDir, @"File3.pdf");
string destinationFileName = Path.Combine(LEAD_VARS.ImagesDir, @"Merged.pdf");
// Merge 1 with (2, 3) and form destination
PDFFile pdfFile = new PDFFile(sourceFileName1);
pdfFile.MergeWith(new string[] { sourceFileName2, sourceFileName2 }, destinationFileName);
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document